﻿<%@ Page Language="C#" AutoEventWireup="false" CodeFile="recRegistrationform.aspx.cs"
    Inherits="SIPO.Web.Forms.Transaction.recRegistrationform" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Registration Form</title>
    <script src="<%= ResolveUrl("~/scripts/helper.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveUrl("~/scripts/jquery.validate.min.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveUrl("~/scripts/jquery.validate.wrapper.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveUrl("~/scripts/jquery.inputmask.bundle.min.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveUrl("~/scripts/jquery.realperson.min.js") %>" type="text/javascript"></script>

    <style type="text/css">
        .ui-autocomplete
        {
            max-height: 100px;
            overflow-y: auto; /* prevent horizontal scrollbar */
            overflow-x: hidden; /* add padding to account for vertical scrollbar */
            padding-right: 20px;
        }
        .custom-combobox
        {
            position: relative;
            display: inline-block;
        }
        .custom-combobox-toggle
        {
            position: absolute;
            top: 0;
            bottom: 0;
            margin-left: -1px;
            padding: 0; /* support: IE7 */
            height: 1.7em;
            top: 0.1em;
        }
        .custom-combobox-input
        {
            margin: 0;
            padding: 0.3em;
        }
    </style>

    <script type="text/javascript">

        $(document).ready(function () {

            $("#btnNext").button({ icons: { primary: "ui-icon-circle-arrow-e"} });
            $("#btnCancel").button({ icons: { primary: "ui-icon-close"} });
            $("#btnSubmit").button({ icons: { primary: "ui-icon-disk"} });
            $("#btnBack").button({ icons: { primary: "ui-icon-circle-arrow-w"} });

        });

    </script>

    <script type="text/javascript">
        //fungsi untuk membuat captcha menjadi expire dalam satuan waktu
        var timoutNow = 300000; // waktu expire 5 minute

        //var warningTimer;
        var timeoutTimer;

        // Start timers.
        function StartTimers() {
            timeoutTimer = setTimeout("IdleTimeout();", timoutNow);
        }

        // Reset timers.
        function ResetTimers() {
            clearTimeout(timeoutTimer);
            StartTimers();
        }

        function IdleTimeout() {
            $('#txtExpire').val('1');
        }

        function RefreshCaptcha() {

            $('#txtCaptcha1').realperson('destroy');
            $('#txtCaptcha1').realperson({
                regenerate: 'Klik untuk mengubah',
                length: 5,
                includeNumbers: true
            });
            $('#txtCaptcha1').val('');
            $('#txtCaptcha1').focus();
            $('#txtExpire').val('0');
            ResetTimers();

        }
    
    </script>
    <script type="text/javascript" language="javascript">

        (function ($) {

            $.widget("custom.combobox", {
                _create: function () {
                    this.wrapper = $("<span>")
          .addClass("custom-combobox")
          .insertAfter(this.element);

                    this.element.hide();
                    this._createAutocomplete();
                    this._createShowAllButton();
                },

                _createAutocomplete: function () {
                    var selected = this.element.children(":selected"),
          value = selected.val() ? selected.text() : "";

                    var width = this.element.width() > 100 ? "style='width:" + this.element.width() + "px';" : "";

                    this.input = $("<input " + width + ">")
          .appendTo(this.wrapper)
          .val(value)
          .attr("title", "")
          .addClass("custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left")
          .autocomplete({
              autoFocus: true,
              selectFirst: true,
              delay: 0,
              minLength: 0,
              source: $.proxy(this, "_source")
          })
          .tooltip({
              tooltipClass: "ui-state-highlight"
          });

                    this._on(this.input, {
                        autocompleteselect: function (event, ui) {
                            ui.item.option.selected = true;
                            this._trigger("select", event, {
                                item: ui.item.option
                            });

                            var idOfCaller = this.element.attr('id');
                            switch (idOfCaller.toLowerCase()) {
                                case ("ddlsector"):
                                    $('#ddlSector').change();
                                    break;
                                case ("ddlsubsector"):
                                    $('#ddlSubSector').change();
                                    break;
                                case ("ddlsubsubsector"):
                                    $('#ddlSubSubSector').change();
                                    break;
                                case ("ddlkota"):
                                    $('#ddlKota').change();
                                    break;
                                //                                case ("ddlregistrationemisiontype"):                                                       
                                //                                    $('#ddlRegistrationEmisionType').change();                                                       
                                //                                    break;                                                       
                                case ("ddlwilayah"):
                                    $('#ddlWilayah').change();
                                    break;
                                default:
                                    break;
                            }

                        },

                        autocompletechange: "_removeIfInvalid"
                    });
                },

                _createShowAllButton: function () {
                    var input = this.input,
          wasOpen = false;

                    $("<a>")
          .attr("tabIndex", -1)
          .attr("title", "Tamplikan Semua Item")
          .tooltip()
          .appendTo(this.wrapper)
          .button({
              icons: {
                  primary: "ui-icon-triangle-1-s"
              },
              text: false
          })
          .removeClass("ui-corner-all")
          .addClass("custom-combobox-toggle ui-corner-right")
          .mousedown(function () {
              wasOpen = input.autocomplete("widget").is(":visible");
          })
          .click(function () {
              input.focus();

              // Close if already visible
              if (wasOpen) {
                  return;
              }

              // Pass empty string as value to search for, displaying all results
              input.autocomplete("search", "");
          });
                },

                _source: function (request, response) {
                    var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i");
                    response(this.element.children("option").map(function () {
                        var text = $(this).text();
                        if (this.value && (!request.term || matcher.test(text)))
                            return {
                                label: text,
                                value: text,
                                option: this
                            };
                    }));
                },

                _removeIfInvalid: function (event, ui) {

                    // Selected an item, nothing to do
                    if (ui.item) {
                        return;
                    }

                    // Search for a match (case-insensitive)
                    var value = this.input.val(),
          valueLowerCase = value.toLowerCase(),
          valid = false;
                    this.element.children("option").each(function () {
                        if ($(this).text().toLowerCase() === valueLowerCase) {
                            this.selected = valid = true;
                            return false;
                        }
                    });

                    // Found a match, nothing to do
                    if (valid) {
                        return;
                    }

                    // Remove invalid value
                    this.input
          .val("")
          .attr("title", value + " tidak ditemukan")
          .tooltip("open");
                    this.element.val("");
                    this._delay(function () {
                        this.input.tooltip("close").attr("title", "");
                    }, 2500);
                    this.input.data("ui-autocomplete").term = "";
                },

                _destroy: function () {
                    this.wrapper.remove();
                    this.element.show();
                },
                autocomplete: function (value, text) {
                    this.element.val(value);
                    this.input.val(text);
                }
            });
        })(jQuery);

        $(function () {

            $("#ddlSector").combobox();
            //$("#ddlRegistrationEmisionType").combobox();
            $("#ddlSubSector").combobox();
            //$("#ddlJenisEmisi").combobox();
            $("#ddlSubSubSector").combobox();
            $("#ddlWilayah").combobox();
            $("#ddlKota").combobox();
        });

    </script>
    <script type="text/javascript">

        $(document).ready(function () {

            var debtorId = $('#<%= hfDebtorID.ClientID %>').val();

            if (debtorId != "") {
                GetWilayahAndCity();
                $("#ddlWilayah").parent().find("input.ui-autocomplete-input").autocomplete("option", "disabled", true).prop("disabled", true);
                $("#ddlWilayah").parent().find("a.ui-button").button("disable");
                $("#ddlKota").parent().find("input.ui-autocomplete-input").autocomplete("option", "disabled", true).prop("disabled", true);
                $("#ddlKota").parent().find("a.ui-button").button("disable");
            }

            var IsInternalReg = '<%= Request.Params["RegInternal"] %>';

            $('#ddlKota').combobox('autocomplete', "", "-- pilih kota --");
            $('#ddlWilayah').combobox('autocomplete', "", "-- pilih provinsi --");

            $('#txtCaptcha1').realperson({
                regenerate: 'Klik untuk mengubah',
                length: 5,
                includeNumbers: true

            });

            $('#txtCaptcha1').upperCase();

            var subsectorname = $('#<%= hfSubSectorName.ClientID %>').val();
            if (subsectorname == "") {
                $('#ddlRegistrationEmisionType').attr('disabled', 'disabled');
                $('#ddlSector').combobox('autocomplete', "", "-- pilih sektor --");
                $('#ddlSubSector').combobox('autocomplete', "", "-- pilih sub sektor --");
                $('#ddlSubSubSector').combobox('autocomplete', "", "-- pilih sub sub sektor --");
                //                $('#txtddlSector').val('');
                //                $('#txtddlSubSector').val('');
                //                $('#txtddlSubSubSector').val('');
            }
            else {
                var sectorid = $('#<%= hfSectorID.ClientID %>').val();
                var sectorcode = $('#<%= hfSectorCode.ClientID %>').val();
                var sectorname = $('#<%= hfSectorName.ClientID %>').val();
                //                $('#txtddlSector').val(sectorid);
                $('#ddlSector').combobox('autocomplete', sectorid, sectorcode + "-" + sectorname);

                var subsectorid = $('#<%= hfSubSectorID.ClientID %>').val();
                var subsectorcode = $('#<%= hfSubSectorCode.ClientID %>').val();
                var subsectorname = $('#<%= hfSubSectorNames.ClientID %>').val();
                //                $('#txtddlSubSector').val(subsectorid);
                $('#ddlSubSector').combobox('autocomplete', subsectorid, subsectorcode + "-" + subsectorname);

                var subsubsectorid = $('#<%= hfSubSubSectorID.ClientID %>').val();
                var subsubsectorcode = $('#<%= hfSubSubSectorCode.ClientID %>').val();
                var subsubsectorname = $('#<%= hfSubSubSectorName.ClientID %>').val();
                //                $('#txtddlSubSubSector').val(subsubsectorid);
                $('#ddlSubSubSector').combobox('autocomplete', subsubsectorid, subsubsectorcode + "-" + subsubsectorname);

                var subSubSectorId = $("#ddlSubSubSector option:selected").val();
            }

            $("#msgErrorChangePassword").hide();
            $("#fsKonfirmasi").hide();
            $("#tableCaptcha").hide();

            $("#btnSubmit").hide();
            $("#btnBack").hide();

            Disabled();
            DisabledJenisEmisi();

            var id = $('#<%= hfID.ClientID %>').val();

            if (id != 0) {
                $("#fsUserLogin").hide();
            }

            $.validator.addMethod("regex", function (value, element, parameters) {
                var re = new RegExp(parameters);
                return re.test(value);
            });

            // 1. prepare the validation rules and messages.
            var rules = {
                txtUserId: {
                    required: true,
                    maxlength: 25
                },
                txtPasswordRegistration: {
                    required: true,
                    maxlength: 10
                },
                txtConfirmPassword: {
                    required: true,
                    maxlength: 10
                },
                txtNPWP: { regex: '[0-9][0-9].[0-9][0-9][0-9].[0-9][0-9][0-9].[0-9]-[0-9][0-9][0-9].[0-9][0-9][0-9]' },
                txtDebtorName: "required",
                ddlSector: "required",
                ddlSubSector: "required",
                ddlSubSubSector: "required",
                ddlRegistrationEmisionType: "required",
                txtAlamat1 : "required",
                txtEmail: {
                    required: true,
                    email: true,
                    maxlength: 50
                }
            };
            var messages = {
            txtAlamat1 : "Alamat harus di isi",
                txtUserId: {
                    required: "Kode User harus di isi",
                    maxlength: "Panjang Kode User maksimal 25 karakter"
                },
                txtPasswordRegistration: {
                    required: "Password harus di isi",
                    maxlength: "Panjang Password maksimal 10 karakter"
                },
                txtConfirmPassword: {
                    required: "Konfirmasi Password harus di isi",
                    maxlength: "Panjang Konfirmasi Password maksimal 10 karakter"
                },
                txtNPWP: "Format NPWP harus benar 00.000.000.0-000.000",
                txtDebtorName: "Nama Perusahaan harus di isi",
                ddlSector: "Sektor Jenis Usaha harus di isi",
                ddlSubSector: "Sub Sektor Jenis Usaha harus di isi",
                ddlSubSubSector: "Sub Sub Sektor Jenis Usaha harus di isi",
                ddlRegistrationEmisionType: "Jenis Registrasi Emisi harus di isi",
                txtEmail: {
                    required: "Email harus di isi",
                    email: "Format alamat Email harus berformat xxx@domain.xxx",
                    maxlength: "Panjang email maksimal 50 karakter "
                }

            };

            $("#txtUserId").inputmask("Regex", { regex: "[A-Za-z-.0-9_]*" });

            $("#txtNPWP").inputmask('99.999.999.9-999.999');

            $("#txtDebtorName").inputmask("Regex", { regex: "[A-Za-z-.0-9 ]*" });

            $("#txtAlamat1").inputmask("Regex", { regex: "[A-Za-z-.0-9 ]*" });

            $("#txtAlamat2").inputmask("Regex", { regex: "[A-Za-z-.0-9 ]*" });

            $("#txtAlamat3").inputmask("Regex", { regex: "[A-Za-z-.0-9 ]*" });

            $("#txtKodePos").inputmask("Regex", { regex: "[0-9]*" });

            $("#txtTelpon").inputmask("Regex", { regex: "[0-9+-]*" });

            $("#txtFax").inputmask("Regex", { regex: "[0-9-+]*" });

            $("#txtEmail").inputmask("Regex", { regex: "[A-Za-z_.@0-9_]*" });

            $("#txtWebsite").inputmask("Regex", { regex: "[A-Za-z-.0-9_/: ]*" });

            $("#txtNilaiEmisi").inputmask("decimal", { radixPoint: ",", autoGroup: true, groupSeparator: ".", groupSize: 3, digits: 2, repeat: 18});

            // 2. Initiate the validator
            var validator = new jQueryValidatorWrapper("form1", rules, messages);

            // 3. Set the click event to do the validation
            $("#btnNext").click(function () {

                var subsectorname = $('#<%= hfSubSectorName.ClientID %>').val();
                var invoicevalue = 0;

                var sectorid = $("#ddlSector option:selected").val();
                var subsectorid = $("#ddlSubSector option:selected").val();
                var subsubsectorid = $("#ddlSubSubSector option:selected").val();

                //                var sectorid = $('#txtddlSector').val();
                //                var subsectorid = $('#txtddlSubSector').val();
                //                var subsubsectorid = $('#txtddlSubSubSector').val();

                // invoicevalue = $('#hfInvoiceValue').val();

                if ($('#<%= hfInvoiceValue.ClientID %>').val() == 0)
                    invoicevalue = $('#<%= hfValue.ClientID %>').val();
                else
                    invoicevalue = $('#hfInvoiceValue').val();
                if (sectorid != "" && subsectorid != "" && subsubsectorid != "") {
                    if (parseFloat(invoicevalue) == 0) {

                        $('#ddlSector').combobox('autocomplete', "", "-- pilih sektor --");
                        $('#ddlSubSector').combobox('autocomplete', "", "-- pilih sub sektor --");
                        $('#ddlSubSubSector').combobox('autocomplete', "", "-- pilih sub sub sektor --");

                        if (subsectorname == "") {
                            $('#ddlRegistrationEmisionType').attr('disabled', 'disabled');
                            //                            $('#txtddlSector').val('');
                            //                            $('#txtddlSubSector').val('');
                            //                            $('#txtddlSubSubSector').val('');
                        }
                        Disabled();
                        DisabledJenisEmisi();
                        alert('Jenis Usaha ini belum ada Tarif nya!');
                        return;
                    }
                }
                if (!validator.validate())
                    return;
                else {
                    var email = $('#txtEmail').val();
                    var username = $('#txtUserId').val();
                    var confirmpassword = $('#txtConfirmPassword').val();
                    var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/validasiemailbyuser.ashx?email=' + email + '&password=' + confirmpassword + '&username=' + username + '") %>';

                    if (email != "" && username != "" && confirmpassword != "") {

                        jQuery.ajax({
                            type: 'POST',
                            url: handlerUrl,
                            contentType: 'application/json',
                            dataType: 'json',
                            success: function (data) {
                                if (data.Sector > 0) {
                                    alert("email sudah ada !!");
                                    $('#txtEmail').val('');
                                    $('#txtEmail').focus();
                                }
                                else {
                                    $("#fsUserLogin").hide();
                                    $("#fsProfilDebitur").hide();
                                    $("#fsKonfirmasi").show();
                                    $("#btnSubmit").show();
                                    $("#btnBack").show();
                                    $("#btnNext").hide();

                                    ValidasiNPWP();
                                    DisplayTarif();
                                    if (IsInternalReg == 'undefined' || IsInternalReg.toString() == "")
                                        $("#tableCaptcha").show();
                                }
                            },
                            error: function () {
                                alert('Error!');
                            }
                        });
                    }


                }
            });

            function DisplayTarif() {
                var subsectorname = $('#<%= hfSubSectorName.ClientID %>').val();
                var invoicevalue = 0;
                var sector = "";
                var subsector = "";
                var subsubsector = "";
                var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/getbespelled.ashx?invoicevalue=") %>';
                if (subsectorname != "") {
                    var sectorcode = $('#<%= hfSectorCode.ClientID %>').val();
                    var sectorname = $('#<%= hfSectorName.ClientID %>').val();
                    sector = sectorcode + '-' + sectorname;
                    sector = sector.split('-');
                    var subsectorcode = $('#<%= hfSubSectorCode.ClientID %>').val();
                    var subsectorname = $('#<%= hfSubSectorNames.ClientID %>').val();
                    subsector = subsectorcode + '-' + subsectorname;
                    subsector = subsector.split('-');
                    var subsubsectorcode = $('#<%= hfSubSubSectorCode.ClientID %>').val();
                    var subsubsectorname = $('#<%= hfSubSubSectorName.ClientID %>').val();
                    subsubsector = subsubsectorcode + '-' + subsubsectorname;
                    subsubsector = subsubsector.split('-');
                }
                else {
                    sector = $("#ddlSector option:selected").text().split('-');
                    subsector = $("#ddlSubSector option:selected").text().split('-');
                    subsubsector = $("#ddlSubSubSector option:selected").text().split('-');
                }

                var registrasiemisi = $("#ddlRegistrationEmisionType option:selected").text();
                var registrasiemisiid = $("#ddlRegistrationEmisionType option:selected").val();
                var jenisemisi = $("#ddlJenisEmisi option:selected").text();
                var jenisemisiid = $("#ddlJenisEmisi option:selected").val();
                $subSectors = $('#ddlSubSector');
                $subSubSectors = $('#ddlSubSubSector');

                if ($('#<%= hfInvoiceValue.ClientID %>').val() == 0)
                    invoicevalue = $('#<%= hfValue.ClientID %>').val();
                else
                    invoicevalue = $('#hfInvoiceValue').val();

                var money = parseFloat(invoicevalue);

                $.ajax({
                    type: 'POST',
                    url: handlerUrl + invoicevalue,
                    contentType: 'application/json',
                    dataType: 'json',
                    success: function (data) {
                        if (data.BeSpelled != "") {
                            if (registrasiemisiid != "") {
                                if (subsector[1].toString().toLowerCase() == 'emiten' || subsector[1].toString().toLowerCase() == 'perusahaan publik') {
                                    if (jenisemisiid != "")
                                        $("#lblValidasi").html("Biaya " + $('#<%= hfRegistrationLabel.ClientID %>').val() + " " + registrasiemisi + " - " + jenisemisi + " adalah sebesar Rp" + money.formatMoney(2, ".", ",") + " (" + data.BeSpelled + ")" + ". <br/> Surat setoran akan diberikan setelah proses registrasi ini dikonfirmasi");
                                    else
                                        $("#lblValidasi").html("Biaya " + $('#<%= hfRegistrationLabel.ClientID %>').val() + " " + registrasiemisi + " adalah sebesar Rp" + money.formatMoney(2, ".", ",") + " (" + data.BeSpelled + ")" + ". <br/> Surat setoran akan diberikan setelah proses registrasi ini dikonfirmasi");
                                }
                            }
                            else
                                $("#lblValidasi").html("Biaya " + $('#<%= hfRegistrationLabel.ClientID %>').val() + " " + subsector[1] + " - " + subsubsector[1] + " adalah sebesar Rp" + money.formatMoney(2, ".", ",") + " (" + data.BeSpelled + ")" + ". <br/> Surat setoran akan diberikan setelah proses registrasi ini dikonfirmasi");
                            $('#<%= hfBeSpelled.ClientID %>').val(data.BeSpelled);
                        }
                        else {
                            if (registrasiemisiid != "") {
                                if (subsector[1].toString().toLowerCase() == 'emiten' || subsector[1].toString().toLowerCase() == 'perusahaan publik') {
                                    if (jenisemisiid != "")
                                        $("#lblValidasi").html("Biaya " + $('#<%= hfRegistrationLabel.ClientID %>').val() + " " + registrasiemisi + " - " + jenisemisi + " adalah sebesar Rp" + money.formatMoney(2, ".", ",") + " ");
                                    else
                                        $("#lblValidasi").html("Biaya " + $('#<%= hfRegistrationLabel.ClientID %>').val() + " " + registrasiemisi + " adalah sebesar Rp" + money.formatMoney(2, ".", ",") + " ");
                                }
                            }
                            else
                                $("#lblValidasi").html("Biaya " + $('#<%= hfRegistrationLabel.ClientID %>').val() + " " + subsector[1] + " - " + subsubsector[1] + " adalah sebesar " + money.formatMoney(2, ".", ",") + " ");
                        }
                    },
                    error: function () {
                        alert('Error!');
                    }
                });
            }

            function addPeriod(nStr) {
                nStr += '';
                x = nStr.split('.');
                x1 = x[0];
                x2 = x.length > 1 ? '.' + x[1] : '';
                var rgx = /(\d+)(\d{3})/;
                while (rgx.test(x1)) {
                    x1 = x1.replace(rgx, '$1' + '.' + '$2');
                }
                return x1 + x2;
            }

            $("#btnBack").click(function () {

                $("#fsUserLogin").show();
                $("#fsProfilDebitur").show();
                $("#fsKonfirmasi").hide();

                $("#btnSubmit").hide();
                $("#btnBack").hide();
                $("#btnNext").show();
                $("#btnCancel").show();
                $("#tableCaptcha").hide();

            });

            function Disabled() {
                $('#txtNilaiEmisi').attr('disabled', 'disabled');
                $('#txtNilaiEmisi').val('');
            }
            function DisabledJenisRegistrasi() {
                $('#ddlRegistrationEmisionType').attr('disabled', 'disabled');
                $ddlRegistrationEmisionTypes = $('#ddlRegistrationEmisionType');
                $ddlRegistrationEmisionTypes.get(0).options.length = 0;
                $ddlRegistrationEmisionTypes.get(0).options[0] = new Option("-- pilih jenis registrasi emisi --", "");
            }
            function DisabledJenisEmisi() {
                $('#ddlJenisEmisi').attr('disabled', 'disabled');
                $jenisEmisis = $('#ddlJenisEmisi');
                $jenisEmisis.get(0).options.length = 0;
                $jenisEmisis.get(0).options[0] = new Option("-- pilih Jenis Penawaran Umum --", "");
            }
            function LoadEmisionType() {
                $jenisEmisis = $('#ddlJenisEmisi');
                var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/getemisiontype.ashx") %>';
                $.ajax({
                    type: 'POST',
                    url: handlerUrl,
                    contentType: 'application/json',
                    dataType: 'json',
                    success: function (datas) {
                        $jenisEmisis.get(0).options.length = 0;
                        $jenisEmisis.get(0).options[0] = new Option("-- pilih Jenis Penawaran Umum --", "");
                        $.each(datas, function (i, data) {
                            $jenisEmisis.append('<option value="' + data.EmisionTypeID + '">' + data.EmisionTypeName + '</option>');
                        });
                    },
                    error: function () {
                        alert('Error!');
                    }
                });
            }
            function Enabled() {
                $('#txtNilaiEmisi').removeAttr('disabled');
                //$('#ddlJenisEmisi').removeAttr('disabled');
                //LoadEmisionType();
            }
            function EnabledJenisEmisi() {
                $('#ddlJenisEmisi').removeAttr('disabled');
                LoadEmisionType();
            }
            function EnabledJenisRegistrasi() {
                $('#ddlRegistrationEmisionType').removeAttr('disabled');
                GetRegistrationEmisionType();
            }
            function ValidasiNPWP() {
                var npwp = "";
                var subsectorname = $('#<%= hfSubSectorName.ClientID %>').val();
                if (subsectorname != "")
                    npwp = $('#<%= hfNPWP.ClientID %>').val();
                else
                    npwp = $('#txtNPWP').val();
                var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/validasinpwp.ashx?npwp=") %>';
                if (npwp != "") {
                    jQuery.ajax({
                        type: 'POST',
                        url: handlerUrl + npwp,
                        contentType: 'application/json',
                        dataType: 'json',
                        success: function (datas) {
                            var validasinpwps = '';
                            if (datas.length > 0) {
                                $.each(datas, function (i, data) {
                                    if (data.recSubSector.SubSectorName.toLowerCase() == "emiten" || data.recSector.SectorName.toLowerCase() == "perbankan")
                                        validasinpwps += data.recSubSector.SubSectorName + " \n";
                                    else
                                        validasinpwps += data.recSubSubSector.SubSubSectorName + " \n";
                                    validasinpwps = validasinpwps;
                                    //validasinpwps += data.recSector.SectorName + "-" + data.recSubSector.SubSectorName + "-" + data.recSubSubSector.SubSubSectorName + " \n";
                                });
                                $("#lblTitleValidasiNPWP").html("NPWP sudah terdaftar sebagai Debitur untuk jenis usaha :");
                                $("#lblValidasiNPWP").val(validasinpwps);
                            }
                            else {
                                $("#divlblValidasiNPWP").css({ 'display': 'none' });
                                $("#lblTitleValidasiNPWP").html('');
                                $("#lblValidasiNPWP").val("");
                            }
                        },
                        error: function () {
                            alert('Error!');
                        }
                    });
                }
                else {
                    $("#divlblValidasiNPWP").css({ 'display': 'none' });
                    $("#lblTitleValidasiNPWP").html('');
                    $("#lblValidasiNPWP").val("");
                }
            }


            function ValidasiNPWPAndSector() {
                var npwp = $('#txtNPWP').val();
                var sectorid = $("#ddlSector option:selected").val();
                var subsectorid = $("#ddlSubSector option:selected").val();
                var subsubsectorid = $("#ddlSubSubSector option:selected").val();
                var sector = $("#ddlSector option:selected").text().split('-');
                var subsector = $("#ddlSubSector option:selected").text().split('-');
                var subsubsector = $("#ddlSubSubSector option:selected").text().split('-');
                $subSectors = $('#ddlSubSector');
                $subSubSectors = $('#ddlSubSubSector');
                var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/validasibynpwpjenisusahaunion.ashx?npwp=' + npwp + '&sectorId=' + sectorid + '&subSectorId=' + subsectorid + '&subSubSectorId=' + subsubsectorid + ' ") %>';
                if (npwp != "" && sectorid != "" && subsectorid != "" && subsubsectorid != "") {
                    jQuery.ajax({
                        type: 'POST',
                        url: handlerUrl,
                        contentType: 'application/json',
                        dataType: 'json',
                        success: function (data) {
                            if (data.NPWP != "") {
                                //$('#<%= hfID.ClientID %>').val(data.DebtorID)
                                if (subsector[1].toString().toLowerCase() != 'emiten') {
                                    alert("NPWP " + npwp + " sudah terdaftar sebagai Debitur untuk jenis usaha " + sector[1] + "-" + subsector[1] + "-" + subsubsector[1] + " ");
                                    Disabled();
                                    $subSectors.get(0).options.length = 0;
                                    $subSectors.get(0).options[0] = new Option("-- pilih sub sector --", "");
                                    $subSubSectors.get(0).options.length = 0;
                                    $subSubSectors.get(0).options[0] = new Option("-- pilih sub sub sector --", "");
                                    GetSector();
                                    $('#ddlSector').combobox('autocomplete', "", "-- pilih sektor --");
                                    $('#ddlSubSector').combobox('autocomplete', "", "-- pilih sub sektor --");
                                    $('#ddlSubSubSector').combobox('autocomplete', "", "-- pilih sub sub sektor --");

                                    $('#txtddlSector').val('');
                                    $('#txtddlSubSector').val('');
                                    $('#txtddlSubSubSector').val('');
                                }

                            }
                            else {
                                // alert("NPWP " + npwp + " belum terdaftar sebagai Debitur untuk jenis usaha " + sector[1] + "-" + subsector[1] + "-" + subsubsector[1] + " ");
                                //Enabled();
                            }
                        },
                        error: function () {
                            alert('Error!');
                        }
                    });
                }
                //                else {
                //                    alert('Isi NPWP terlebih dahulu!');
                //                }
            }

            function CheckPassword() {
                var npwp = $('#txtNPWP').val();
                var usercode = $('#txtUserId').val();
                var password = $('#txtPasswordRegistration').val();
                var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/validasiuserpassword.ashx?usercode=' + usercode + '&password=' + password + '") %>';
                if (usercode != "" && password != "" && npwp != "") {
                    jQuery.ajax({
                        type: 'POST',
                        url: handlerUrl,
                        contentType: 'application/json',
                        dataType: 'json',
                        success: function (data) {
                            if (data.Status == "NOTOK") {
                                alert('Password Anda Salah!');
                                $("#txtPasswordRegistration").focus();
                                $("#txtPasswordRegistration").val('');
                            }
                        },
                        error: function () {
                            alert('Error!');
                        }
                    });
                }
            }

            function CheckPassword2() {
                var npwp = $('#txtNPWP').val();
                var usercode = $('#txtUserId').val();
                var password = $('#txtPasswordRegistration').val();
                var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/validasiuserpassword.ashx?usercode=' + usercode + '&password=' + password + '") %>';
                if (usercode != "" && password != "" && npwp != "") {
                    jQuery.ajax({
                        type: 'POST',
                        url: handlerUrl,
                        contentType: 'application/json',
                        dataType: 'json',
                        success: function (data) {
                            if (data.Status == "NOTOK") {
                                alert('Cek Password Anda!');
                                $("#txtPasswordRegistration").focus();
                                $("#txtPasswordRegistration").val('');
                            }
                        },
                        error: function () {
                            alert('Error!');
                        }
                    });
                }
            }

            function CheckUser() {
                $('#<%= hfIsUser.ClientID %>').val(0);
                var npwp = $('#txtNPWP').val();
                var usercode = $('#txtUserId').val();
                var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/validasinpwpunion.ashx?npwp=") %>';
                var handlerUrl2 = '<%= ResolveUrl("~/AjaxHandler/Loaddata/validasiuserid.ashx?usercode=") %>';
                var handlerUrlCheckUser = '<%= ResolveUrl("~/AjaxHandler/Loaddata/checkuser.ashx?method=union&npwp=' + npwp + '&usercode=' + usercode + '") %>';
                if (npwp != "") {
                    jQuery.ajax({
                        type: 'POST',
                        url: handlerUrl + npwp,
                        contentType: 'application/json',
                        dataType: 'json',
                        success: function (data) {
                            if (data.NPWP == "") {
                                $(":radio[value=2]").attr('checked', true);
                                $("input[name='rbKonfirmasi']").attr('disabled', 'disabled');
                                if (usercode != "") {
                                    jQuery.ajax({
                                        type: 'POST',
                                        url: handlerUrl2 + usercode,
                                        contentType: 'application/json',
                                        dataType: 'json',
                                        success: function (data) {
                                            if (data.UserCode != "") {
                                                alert('User ID sudah ada, Coba User ID yang lain!');
                                                $("#txtUserId").focus();
                                                $("#txtUserId").val('');
                                                $('#<%= hfIsUser.ClientID %>').val(1);
                                            }
                                        },
                                        error: function () {
                                            alert('Error!');
                                        }
                                    });
                                }
                            }
                            else {
                                $(":radio[value=1]").attr('checked', true);
                                $("input[name='rbKonfirmasi']").attr('enabled', 'enabled');
                                if (usercode != "") {
                                    jQuery.ajax({
                                        type: 'POST',
                                        url: handlerUrl2 + usercode,
                                        contentType: 'application/json',
                                        dataType: 'json',
                                        success: function (data) {
                                            if (data.UserCode != "") {
                                                jQuery.ajax({
                                                    type: 'POST',
                                                    url: handlerUrlCheckUser,
                                                    contentType: 'application/json',
                                                    dataType: 'json',
                                                    success: function (data) {
                                                        if (data.NPWP == "") {
                                                            alert('User ID sudah ada, Coba User ID yang lain!');
                                                            $("#txtUserId").focus();
                                                            $("#txtUserId").val('');
                                                            $('#<%= hfIsUser.ClientID %>').val(1);
                                                        }
                                                    },
                                                    error: function () {
                                                        alert('Error!');
                                                    }
                                                });

                                            }
                                        },
                                        error: function () {
                                            alert('Error!');
                                        }
                                    });
                                }
                            }
                        },
                        error: function () {
                            alert('Error!');
                        }
                    });
                }
            }

            function GetWilayahAndCity() {
                var npwp = $('#txtNPWP').val();
                var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/getdebtorbynpwp.ashx?npwp=' + npwp + '") %>';
                var handlerUrl2 = '<%= ResolveUrl("~/AjaxHandler/Loaddata/getregistrationbynpwp.ashx?npwp=' + npwp + '") %>';
                if (npwp != "") {
                    jQuery.ajax({
                        type: 'POST',
                        url: handlerUrl,
                        contentType: 'application/json',
                        dataType: 'json',
                        success: function (data) {
                            if (data.DebtorName != "") {
                                if (data.RegionId != 0) {
                                    $('#ddlWilayah').combobox('autocomplete', data.RegionId, data.RegionCode + " - " + data.RegionName);
                                    if (data.CityId != 0) {
                                        $citys = $('#ddlKota');
                                        var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/getcity.ashx?region_id=") %>';
                                        $.ajax({
                                            type: 'POST',
                                            url: handlerUrl + data.RegionId,
                                            contentType: 'application/json',
                                            dataType: 'json',
                                            success: function (datas) {
                                                $citys.get(0).options.length = 0;
                                                $citys.get(0).options[0] = new Option("-- pilih kota --", "");
                                                $.each(datas, function (i, data) {
                                                    $citys.append('<option value="' + data.CityID + '">' + data.CityCode + ' - ' + data.CityName + '</option>');
                                                });
                                                $('#ddlKota').combobox('autocomplete', data.CityId, data.CityCode + ' - ' + data.CityName);
                                            },
                                            error: function () {
                                                alert('Error!');
                                            }
                                        });
                                    }
                                }
                            }
                            else {
                                jQuery.ajax({
                                    type: 'POST',
                                    url: handlerUrl2,
                                    contentType: 'application/json',
                                    dataType: 'json',
                                    success: function (data) {
                                        if (data.DebtorName != "") {
                                            if (data.RegionId != 0) {
                                                $('#ddlWilayah').combobox('autocomplete', data.RegionId, data.RegionCode + " - " + data.RegionName);
                                                if (data.CityId != 0) {
                                                    $citys = $('#ddlKota');
                                                    var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/getcity.ashx?region_id=") %>';
                                                    $.ajax({
                                                        type: 'POST',
                                                        url: handlerUrl + data.RegionId,
                                                        contentType: 'application/json',
                                                        dataType: 'json',
                                                        success: function (datas) {
                                                            $citys.get(0).options.length = 0;
                                                            $citys.get(0).options[0] = new Option("-- pilih kota --", "");
                                                            $.each(datas, function (i, data) {
                                                                $citys.append('<option value="' + data.CityID + '">' + data.CityCode + ' - ' + data.CityName + '</option>');
                                                            });
                                                            $('#ddlKota').combobox('autocomplete', data.CityId, data.CityCode + ' - ' + data.CityName);
                                                        },
                                                        error: function () {
                                                            alert('Error!');
                                                        }
                                                    });
                                                }
                                            }
                                        }
                                    }
                                });
                            }
                        }
                    });
                }
            }

            function GetDebtor() {
                $('#ddlSector').combobox('autocomplete', "", "-- pilih sektor  --");
                $('#ddlSubSector').combobox('autocomplete', "", "-- pilih sub sektor  --");
                $('#ddlSubSubSector').combobox('autocomplete', "", "-- pilih sub sub sektor  --");
                var npwp = $('#txtNPWP').val();
                var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/getdebtorbynpwp.ashx?npwp=' + npwp + '") %>';
                var handlerUrl2 = '<%= ResolveUrl("~/AjaxHandler/Loaddata/getregistrationbynpwp.ashx?npwp=' + npwp + '") %>';
                if (npwp != "") {

                    jQuery.ajax({
                        type: 'POST',
                        url: handlerUrl,
                        contentType: 'application/json',
                        dataType: 'json',
                        success: function (data) {
                            if (data.DebtorName != "") {
                                $("#txtDebtorName").val(data.DebtorName);

                                $("#txtAlamat1").val(data.Address1);
                                $("#txtAlamat2").val(data.Address2);
                                $("#txtAlamat3").val(data.Address3);
                                $("#txtKodePos").val(data.ZipCode);
                                $("#txtTelpon").val(data.Phone);
                                $("#txtFax").val(data.Fax);
                                $("#txtEmail").val(data.Email);
                                $("#txtWebsite").val(data.Website);
                                $("#txtNilaiEmisi").val('');
                                $("#ddlJenisEmisi").val('');
                                if (data.RegionId != 0) {
                                    //  $("#ddlWilayah").val(data.RegionId);
                                    $('#ddlWilayah').combobox('autocomplete', data.RegionId, data.RegionCode + " - " + data.RegionName);

                                    if (data.CityId != 0) {
                                        $citys = $('#ddlKota');
                                        var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/getcity.ashx?region_id=") %>';
                                        $.ajax({
                                            type: 'POST',
                                            url: handlerUrl + data.RegionId,
                                            contentType: 'application/json',
                                            dataType: 'json',
                                            success: function (datas) {
                                                $citys.get(0).options.length = 0;
                                                $citys.get(0).options[0] = new Option("-- pilih kota --", "");
                                                $.each(datas, function (i, data) {
                                                    $citys.append('<option value="' + data.CityID + '">' + data.CityCode + ' - ' + data.CityName + '</option>');
                                                });
                                                //  $('#ddlKota').val(data.CityId);
                                                $('#ddlKota').combobox('autocomplete', data.CityId, data.CityCode + ' - ' + data.CityName);

                                            },
                                            error: function () {
                                                alert('Error!');
                                            }
                                        });
                                    }
                                    else
                                        $('#ddlKota').combobox('autocomplete', "", "-- pilih kota --");
                                }
                                else {
                                    $('#ddlWilayah').combobox('autocomplete', "", "-- pilih provinsi --");
                                    $('#ddlKota').combobox('autocomplete', "", "-- pilih kota --");
                                }
                                if (data.IsIndividual == 1)
                                    $("#checkedPerorangan").attr('checked', true);
                                else
                                    $("#checkedPerorangan").attr('checked', false);
                            }
                            else {
                                //getregistration
                                jQuery.ajax({
                                    type: 'POST',
                                    url: handlerUrl2,
                                    contentType: 'application/json',
                                    dataType: 'json',
                                    success: function (data) {
                                        if (data.DebtorName != "") {
                                            $("#txtDebtorName").val(data.DebtorName);
                                            $("#txtAlamat1").val(data.Address1);
                                            $("#txtAlamat2").val(data.Address2);
                                            $("#txtAlamat3").val(data.Address3);
                                            $("#txtKodePos").val(data.ZipCode);
                                            $("#txtTelpon").val(data.Phone);
                                            $("#txtFax").val(data.Fax);
                                            $("#txtEmail").val(data.Email);
                                            $("#txtWebsite").val(data.Website);
                                            $("#txtNilaiEmisi").val(data.EmisionValue);
                                            if (data.EmisionType != 0) {
                                                $jenisEmisis = $('#ddlJenisEmisi');
                                                var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/getemisiontype.ashx") %>';
                                                $.ajax({
                                                    type: 'POST',
                                                    url: handlerUrl,
                                                    contentType: 'application/json',
                                                    dataType: 'json',
                                                    success: function (datas) {
                                                        $jenisEmisis.get(0).options.length = 0;
                                                        $jenisEmisis.get(0).options[0] = new Option("-- pilih Jenis Penawaran Umum --", "");
                                                        $.each(datas, function (i, data) {
                                                            $jenisEmisis.append('<option value="' + data.EmisionTypeID + '">' + data.EmisionTypeName + '</option>');
                                                        });
                                                        $("#ddlJenisEmisi").val(data.EmisionType);
                                                        //$('#ddlJenisEmisi').combobox('autocomplete', data.EmisionTypeID, data.EmisionTypeName);
                                                    },
                                                    error: function () {
                                                        alert('Error!');
                                                    }
                                                });
                                            }
                                            //else
                                            //$('#ddlJenisEmisi').combobox('autocomplete', "", "-- pilih jenis emisi --");
                                            if (data.RegionId != 0) {
                                                //$("#ddlWilayah").val(data.RegionId);
                                                $('#ddlWilayah').combobox('autocomplete', data.RegionId, data.RegionCode + " - " + data.RegionName);
                                                if (data.CityId != 0) {
                                                    $citys = $('#ddlKota');
                                                    var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/getcity.ashx?region_id=") %>';
                                                    $.ajax({
                                                        type: 'POST',
                                                        url: handlerUrl + data.RegionId,
                                                        contentType: 'application/json',
                                                        dataType: 'json',
                                                        success: function (datas) {
                                                            $citys.get(0).options.length = 0;
                                                            $citys.get(0).options[0] = new Option("-- pilih kota --", "");
                                                            $.each(datas, function (i, data) {
                                                                $citys.append('<option value="' + data.CityID + '">' + data.CityCode + ' - ' + data.CityName + '</option>');
                                                            });
                                                            //$('#ddlKota').val(data.CityId);
                                                            $('#ddlKota').combobox('autocomplete', data.CityId, data.CityCode + ' - ' + data.CityName);
                                                        },
                                                        error: function () {
                                                            alert('Error!');
                                                        }
                                                    });
                                                }
                                                else
                                                    $('#ddlKota').combobox('autocomplete', "", "-- pilih kota --");
                                            }
                                            else {
                                                $('#ddlWilayah').combobox('autocomplete', "", "-- pilih provinsi --");
                                                $('#ddlKota').combobox('autocomplete', "", "-- pilih kota --");
                                            }                                            
                                            if (data.IsIndividual == 1) {                                                
                                                $("#checkedPerorangan").attr('checked', true);
                                            }
                                            else {                                                
                                                $("#checkedPerorangan").attr('checked', false);
                                            }
                                        }
                                        else {
                                            $("#txtDebtorName").val('');
                                            $("#txtAlamat1").val('');
                                            $("#txtAlamat2").val('');
                                            $("#txtAlamat3").val('');
                                            $("#txtKodePos").val('');
                                            $("#txtTelpon").val('');
                                            $("#txtFax").val('');
                                            $("#txtEmail").val('');
                                            $("#txtWebsite").val('');
                                            $("#ddlWilayah").val('');
                                            $('#ddlKota').val('');
                                            $("#txtNilaiEmisi").val('');
                                            $("#ddlJenisEmisi").val('');
                                            $('#ddlKota').combobox('autocomplete', "", "-- pilih kota --");
                                            $('#ddlWilayah').combobox('autocomplete', "", "-- pilih provinsi --");
                                            //$('#ddlJenisEmisi').combobox('autocomplete', "", "-- pilih jenis emisi --");
                                            //$("#checkedPerorangan").removeAttr('checked');
                                            $("#checkedPerorangan").attr('checked', false);
                                        }

                                    },
                                    error: function () {
                                        alert('Error!');
                                    }
                                });
                                //
                            }
                        },
                        error: function () {
                            alert('Error!');
                        }
                    });
                }
            }

            $('#txtNPWP').blur(function () {
                CheckUser();
                ValidasiNPWPAndSector();
                GetDebtor();
                var isuser = $('#<%= hfIsUser.ClientID %>').val();
                if (isuser == 0)
                    CheckPassword();

            });

            $('#txtUserId').blur(function () {
                CheckUser();
                var isuser = $('#<%= hfIsUser.ClientID %>').val();
                if (isuser == 0)
                    CheckPassword2();
            });

            $('#txtPasswordRegistration').blur(function () {
                CheckPassword();
            });


            $('#txtEmail').blur(function () {
                //                if ($('#txtEmail').val() != "") {
                //                    var emailRegex = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
                //                    var match = String($(this).val()).match(emailRegex);
                //                    if (!match) {
                //                        $('#txtEmail').val('');
                //                        alert('Email tidak valid');
                //                    }
                var email = $('#txtEmail').val();
                var username = $('#txtUserId').val();
                var confirmpassword = $('#txtConfirmPassword').val();
                var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/validasiemailbyuser.ashx?email=' + email + '&password=' + confirmpassword + '&username=' + username + '") %>';

                if (email != "" && username != "" && confirmpassword != "") {

                    jQuery.ajax({
                        type: 'POST',
                        url: handlerUrl,
                        contentType: 'application/json',
                        dataType: 'json',
                        success: function (data) {
                            if (data.Sector > 0) {
                                alert("email sudah ada !!");
                                $('#txtEmail').val('');
                                $('#txtEmail').focus();
                            }
                        },
                        error: function () {
                            alert('Error!');
                        }
                    });
                }
            });


            $('#txtWebsite').blur(function () {
                if ($('#txtWebsite').val() != "") {
                    var websiteRegex = new RegExp("^https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,}");
                    var match = String($(this).val()).match(websiteRegex);
                    if (!match) {
                        $('#txtWebsite').val('');
                        alert('Alamat Website tidak valid');
                    }
                }
            });

            function GetTarifBySubSubSectorId() {
                var subsectorname = $('#<%= hfSubSectorName.ClientID %>').val();
                var subsector = "";
                var subSubSectorId = "";
                if (subsectorname != "") {
                    var subsectorcode = $('#<%= hfSubSectorCode.ClientID %>').val();
                    var subsectorname = $('#<%= hfSubSectorNames.ClientID %>').val();
                    subsector = subsectorcode + '-' + subsectorname;
                    subSubSectorId = $('#<%= hfSubSubSectorID.ClientID %>').val();
                }
                else {
                    subsector = $("#ddlSubSector option:selected").text().split('-');
                    subSubSectorId = $("#ddlSubSubSector option:selected").val();
                }
                $subSectors = $('#ddlSubSector');
                $subSubSectors = $('#ddlSubSubSector');
                $registrationEmisionTypes = $('#ddlRegistrationEmisionType');

                var registrationEmisionTypeId = $("#ddlRegistrationEmisionType option:selected").val();
                var handlerUrl = "";
                if (registrationEmisionTypeId == "")
                    handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/gettarifbysubsubsectorid.ashx?subSubSectorId=' + subSubSectorId + '&transtype=perijinan") %>';
                else
                    handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/gettarifbysubsubsectorid.ashx?subSubSectorId=' + subSubSectorId + '&transtype=perijinan&registrationEmisionTypeId=' + registrationEmisionTypeId + '") %>';
                if (subSubSectorId > 0) {
                    jQuery.ajax({
                        type: 'POST',
                        url: handlerUrl,
                        contentType: 'application/json',
                        dataType: 'json',
                        success: function (data) {
                            if (data.TariffID != 0) {
                                //alert(data.Value);
                                $('#<%= hfValue.ClientID %>').val(data.Value);
                                $('#<%= hfInvoiceValue.ClientID %>').val(0);
                                $('#<%= hfTarifID.ClientID %>').val(data.TariffID);
                                $('#<%= hfRegistrationLabel.ClientID %>').val(data.RegistrationLabelName);
                                if (data.IsFormula == 1) {
                                    Enabled();
                                    //EnabledJenisEmisi();
                                    $('#<%= hfMinValue.ClientID %>').val(data.MinValue);
                                    $('#<%= hfMaxValue.ClientID %>').val(data.MaxValue);
                                    $('#<%= hfPercentage.ClientID %>').val(data.Percentage);
                                }
                                else {
                                    Disabled();
                                    //DisabledJenisEmisi();
                                    $('#<%= hfMinValue.ClientID %>').val(0);
                                    $('#<%= hfMaxValue.ClientID %>').val(0);
                                    $('#<%= hfPercentage.ClientID %>').val(0);
                                }
                            }
                            else {

                                alert('Jenis Usaha ini belum ada Tarif nya!');
                                $subSectors.get(0).options.length = 0;
                                $subSectors.get(0).options[0] = new Option("-- pilih sub sector --", "");
                                $subSubSectors.get(0).options.length = 0;
                                $subSubSectors.get(0).options[0] = new Option("-- pilih sub sub sector --", "");
                                GetSector();
                                GetRegistrationEmisionType();
                                Disabled();
                                DisabledJenisEmisi();
                                $('#ddlSector').combobox('autocomplete', "", "-- pilih sektor --");
                                $('#ddlSubSector').combobox('autocomplete', "", "-- pilih sub sektor --");
                                $('#ddlSubSubSector').combobox('autocomplete', "", "-- pilih sub sub sektor --");
                                //$('#ddlRegistrationEmisionType').combobox('autocomplete', "", "-- pilih registrasi emisi --");
                                if (subsectorname == "") {
                                    $('#ddlRegistrationEmisionType').attr('disabled', 'disabled');
                                    $('#txtddlSector').val('');
                                    $('#txtddlSubSector').val('');
                                    $('#txtddlSubSubSector').val('');
                                }
                            }
                        },
                        error: function () {
                            alert('Error!');
                        }
                    });
                }
                else {
                    Disabled();
                    DisabledJenisEmisi();
                    //DisabledJenisRegistrasi();
                    if (subsector[1].toString().toLowerCase() == 'emiten') {
                        GetRegistrationEmisionType();
                    }
                    else {
                        $('#ddlRegistrationEmisionType').removeAttr('disabled');
                    }

                }
            }

            function GetSector() {
                $sectors = $('#ddlSector');
                var handlerUrlSector = '<%= ResolveUrl("~/AjaxHandler/Loaddata/getsector.ashx") %>';
                $.ajax({
                    type: 'POST',
                    url: handlerUrlSector,
                    contentType: 'application/json',
                    dataType: 'json',
                    success: function (datas) {
                        $sectors.get(0).options.length = 0;
                        $sectors.get(0).options[0] = new Option("-- pilih sector --", "");
                        $.each(datas, function (i, data) {
                            $sectors.append('<option value="' + data.SectorID + '">' + data.SectorCode + '-' + data.SectorName + '</option>');
                        });
                    },
                    error: function () {
                        alert('Error!');
                    }
                });
            };

            function GetRegistrationEmisionType() {
                $registrationEmisionTypes = $('#ddlRegistrationEmisionType');
                var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/getregistrationemisiontype.ashx") %>';
                $.ajax({
                    type: 'POST',
                    url: handlerUrl,
                    contentType: 'application/json',
                    dataType: 'json',
                    success: function (datas) {
                        $registrationEmisionTypes.get(0).options.length = 0;
                        $registrationEmisionTypes.get(0).options[0] = new Option("-- pilih jenis registrasi emisi --", "");
                        $.each(datas, function (i, data) {
                            $registrationEmisionTypes.append('<option value="' + data.RegistrationEmisionTypeID + '">' + data.RegistrationEmisionTypeName + '</option>');
                        });
                    },
                    error: function () {
                        alert('Error!');
                    }
                });
            };

            function GetRegistrationEmisionTypeById() {
                var registrationEmisionTypeId = $('#ddlRegistrationEmisionType').val();
                var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/getregistrationemisiontype.ashx?registrationEmisionTypeId=' + registrationEmisionTypeId + '") %>';
                if (registrationEmisionTypeId != "") {
                    jQuery.ajax({
                        type: 'POST',
                        url: handlerUrl,
                        contentType: 'application/json',
                        dataType: 'json',
                        success: function (data) {
                            if (data.IsEmision == 1) {
                                EnabledJenisEmisi();
                            }
                            else {
                                DisabledJenisEmisi();
                            }
                        },
                        error: function () {
                            alert('Error!');
                        }
                    });
                }
            }

            $('#ddlSector').change(function () {
                $('#ddlSubSector').combobox('autocomplete', "", "-- pilih sub sektor --");
                $('#ddlSubSubSector').combobox('autocomplete', "", "-- pilih sub sub sektor --");
                //$('#ddlRegistrationEmisionType').combobox('autocomplete', "", "-- pilih registrasi emisi --");
                //$('#ddlJenisEmisi').combobox('autocomplete', "", "-- pilih jenis emisi --");

                var sectorId = $("#ddlSector option:selected").val();
                $('#txtddlSector').val(sectorId);
                $('#txtddlSubSector').val('');
                $('#txtddlSubSubSector').val('');

                $subSectors = $('#ddlSubSector');
                $subSubSectors = $('#ddlSubSubSector');
                Disabled();
                DisabledJenisEmisi();
                DisabledJenisRegistrasi();
                if (sectorId > 0) {
                    var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/getsubsector.ashx?method=registrasi&sector_id=") %>';

                    $.ajax({
                        type: 'POST',
                        url: handlerUrl + sectorId,
                        contentType: 'application/json',
                        dataType: 'json',
                        success: function (datas) {
                            $subSectors.get(0).options.length = 0;
                            $subSectors.get(0).options[0] = new Option("-- pilih sub sector --", "");
                            $subSubSectors.get(0).options.length = 0;
                            $subSubSectors.get(0).options[0] = new Option("-- pilih sub sub sector --", "");
                            $.each(datas, function (i, data) {
                                $subSectors.append('<option value="' + data.SubSectorID + '">' + data.SubSectorCode + '-' + data.SubSectorName + '</option>');
                            });

                            $subSectors.bind("change", function () {
                                GetSubSubSector($(this).val());
                            });
                        },
                        error: function () {
                            alert('Error!');
                        }
                    });
                }
                else {
                    $subSectors.get(0).options.length = 0;
                    $subSectors.get(0).options[0] = new Option("-- pilih sub sector --", "");
                    $subSubSectors.get(0).options.length = 0;
                    $subSubSectors.get(0).options[0] = new Option("-- pilih sub sub sector --", "");
                }
                //GetTarifBySubSubSectorId();
            });


            function GetSubSubSector(subsectorID) {
                $subSubSectors = $('#ddlSubSubSector');
                if (subsectorID > 0) {
                    var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/getsubsubsector.ashx?method=registrasi&subsector_id=") %>';
                    $.ajax({
                        type: 'POST',
                        url: handlerUrl + subsectorID,
                        contentType: 'application/json',
                        dataType: 'json',
                        success: function (datas) {
                            $subSubSectors.get(0).options.length = 0;
                            $subSubSectors.get(0).options[0] = new Option("-- pilih sub sub sector --", "");

                            $.each(datas, function (i, data) {
                                $subSubSectors.append('<option value="' + data.SubSubSectorID + '">' + data.SubSubSectorCode + '-' + data.SubSubSectorName + '</option>');
                            });
                        },
                        error: function () {
                            $subSubSectors.get(0).options.length = 0;
                            alert("Gagal isi sub sub sector");
                        }
                    });
                }
                else {
                    $subSubSectors.get(0).options.length = 0;
                    $subSubSectors.get(0).options[0] = new Option("-- pilih sub sub sector --", "");
                }
                //GetTarifBySubSubSectorId();
            }

            $('#ddlSubSubSector').change(function () {

                //$('#ddlRegistrationEmisionType').combobox('autocomplete', "", "-- pilih registrasi emisi --");
                //$('#ddlJenisEmisi').combobox('autocomplete', "", "-- pilih jenis emisi --");
                var subsubsectorid = $("#ddlSubSubSector option:selected").val();
                $('#txtddlSubSubSector').val(subsubsectorid);
                // $('#ddlRegistrationEmisionType').val('');
                var registrationEmisionTypeId = $('#ddlRegistrationEmisionType').val();
                if (registrationEmisionTypeId != "")
                    GetRegistrationEmisionType();
                DisabledJenisEmisi();
                Disabled();
                GetTarifBySubSubSectorId();
                ValidasiNPWPAndSector();

            });

            $('#ddlSubSector').change(function () {
                $('#ddlSubSubSector').combobox('autocomplete', "", "-- pilih sub sub sektor --");
                //$('#ddlRegistrationEmisionType').combobox('autocomplete', "", "-- pilih registrasi emisi --");
                //$('#ddlJenisEmisi').combobox('autocomplete', "", "-- pilih jenis emisi --");

                var subsector = $("#ddlSubSector option:selected").text().split('-');
                $('#txtddlSubSector').val(subsector[0]);
                $('#txtddlSubSubSector').val('');
                if (subsector[1].toString().toLowerCase() == 'emiten') {
                    $('#ddlRegistrationEmisionType').removeAttr('disabled');
                    GetRegistrationEmisionType();
                }
                else {
                    $('#ddlRegistrationEmisionType').attr('disabled', 'disabled');
                    Disabled();
                    DisabledJenisEmisi();
                    DisabledJenisRegistrasi();
                }
            });

            $('#ddlRegistrationEmisionType').change(function () {
                //$('#ddlJenisEmisi').combobox('autocomplete', "", "-- pilih jenis emisi --");
                $('#txtNilaiEmisi').val('');
                GetTarifBySubSubSectorId();
                GetRegistrationEmisionTypeById();
            });

            $('#txtNilaiEmisi').blur(function () {

                var subsectorname = $('#<%= hfSubSectorName.ClientID %>').val();
                var subSubSectorId = "";
                if (subsectorname != "")
                    subSubSectorId = $('#<%= hfSubSubSectorID.ClientID %>').val();
                else
                    subSubSectorId = $("#ddlSubSubSector option:selected").val();

                $registrationEmisionTypes = $('#ddlRegistrationEmisionType');
                var registrationEmisionTypeId = $("#ddlRegistrationEmisionType option:selected").val();
                var handlerUrl = "";

                var nilaiemisi = $('#txtNilaiEmisi').val();
                
                if (registrationEmisionTypeId == "")
                    handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/getemisionvalue.ashx?subSubSectorId=' + subSubSectorId + '&nilaiemisi=' + nilaiemisi + '&transtype=perijinan") %>';
                else
                    handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/getemisionvalue.ashx?subSubSectorId=' + subSubSectorId + '&nilaiemisi=' + nilaiemisi + '&transtype=perijinan&registrationEmisionTypeId=' + registrationEmisionTypeId + '") %>';

                if (subSubSectorId > 0 && nilaiemisi != "") {
                    jQuery.ajax({
                        type: 'POST',
                        url: handlerUrl,
                        contentType: 'application/json',
                        dataType: 'json',
                        success: function (data) {
                            $('#<%= hfValue.ClientID %>').val(data.Value);
                            $('#<%= hfRegistrationLabel.ClientID %>').val(data.RegistrationLabelName);
                            if (data.IsFormula == 1) {
                                //Enabled();
                                $('#<%= hfInvoiceValue.ClientID %>').val(data.InvoiceValue);
                                $('#<%= hfMinValue.ClientID %>').val(data.MinValue);
                                $('#<%= hfMaxValue.ClientID %>').val(data.MaxValue);
                                $('#<%= hfPercentage.ClientID %>').val(data.Percentage);
                            }
                            else {
                                //Disabled();
                                $('#<%= hfMinValue.ClientID %>').val(0);
                                $('#<%= hfMaxValue.ClientID %>').val(0);
                                $('#<%= hfPercentage.ClientID %>').val(0);
                            }
                        },
                        error: function () {
                            alert('Error!');
                        }
                    });
                }
            });

            $('#ddlWilayah').change(function () {
                $('#ddlKota').combobox('autocomplete', "", "-- pilih kota --");
                var regionId = $("#ddlWilayah option:selected").val();
                $citys = $('#ddlKota');
                if (regionId > 0) {
                    var handlerUrl = '<%= ResolveUrl("~/AjaxHandler/Loaddata/getcity.ashx?region_id=") %>';

                    $.ajax({
                        type: 'POST',
                        url: handlerUrl + regionId,
                        contentType: 'application/json',
                        dataType: 'json',
                        success: function (datas) {
                            $citys.get(0).options.length = 0;
                            $citys.get(0).options[0] = new Option("-- pilih kota --", "");
                            $.each(datas, function (i, data) {
                                $citys.append('<option value="' + data.CityID + '">' + data.CityCode + ' - ' + data.CityName + '</option>');
                            });
                        },
                        error: function () {
                            alert('Error!');
                        }
                    });
                }
                else {
                    $citys.get(0).options.length = 0;
                    $citys.get(0).options[0] = new Option("-- pilih kota --", "");
                }
            });

            $("#btnSubmit").click(function () {

                var captchaHash = $("input[name='txtCaptcha1Hash']").val();
                var captcha = $("#txtCaptcha1").val();
                var expire = $('#txtExpire').val();

                if (IsInternalReg.toString() == "" || IsInternalReg == 'undefined') {
                    if (captcha == '') {

                        alert('Captcha harus di isi!');
                        RefreshCaptcha();

                        return false;
                    }
                }
                var pilihregistrasi = $("input[name='rbKonfirmasi']:checked").val();
                if (pilihregistrasi == 3) {
                    parent.$('#dialog1').dialog('close');
                }
                else {
                    var userid = $('#txtUserId').val();
                    var password = $('#txtPasswordRegistration').val();
                    var confirmpassword = $('#txtConfirmPassword').val();
                    var debtorname = $('#txtDebtorName').val();
                    var npwp = $('#txtNPWP').val();
                    var jenisemisi = $("#ddlJenisEmisi option:selected").val();
                    var registrationemisiontypeid = $("#ddlRegistrationEmisionType option:selected").val();
                    var jenisemisitext = $("#ddlJenisEmisi option:selected").text();
                    var registrationemisiontypetext = $("#ddlRegistrationEmisionType option:selected").text();
                    var sectorid = "";
                    var subsectorid = "";
                    var subsubsectorid = "";

                    var sector = "";
                    var subsector = "";
                    var subsubsector = "";
                    var isIndividual = '';
                    var subsectorname = $('#<%= hfSubSectorName.ClientID %>').val();
                    if (subsectorname != "") {
                        sectorid = $('#<%= hfSectorID.ClientID %>').val();
                        var sectorcode = $('#<%= hfSectorCode.ClientID %>').val();
                        var sectorname = $('#<%= hfSectorName.ClientID %>').val();
                        sector = sectorcode + '-' + sectorname;
                        sector = sector.split('-');

                        subsectorid = $('#<%= hfSubSectorID.ClientID %>').val();
                        var subsectorcode = $('#<%= hfSubSectorCode.ClientID %>').val();
                        var subsectorname = $('#<%= hfSubSectorNames.ClientID %>').val();
                        subsector = subsectorcode + '-' + subsectorname;
                        subsector = subsector.split('-');
                        subsubsectorid = $('#<%= hfSubSubSectorID.ClientID %>').val();
                        var subsubsectorcode = $('#<%= hfSubSubSectorCode.ClientID %>').val();
                        var subsubsectorname = $('#<%= hfSubSubSectorName.ClientID %>').val();
                        subsubsector = subsubsectorcode + '-' + subsubsectorname;
                        subsubsector = subsubsector.split('-');
                        isIndividual = false;
                    }
                    else {
                        sectorid = $("#ddlSector option:selected").val();
                        subsectorid = $("#ddlSubSector option:selected").val();
                        subsubsectorid = $("#ddlSubSubSector option:selected").val();

                        sector = $("#ddlSector option:selected").text().split('-');
                        subsector = $("#ddlSubSector option:selected").text().split('-');
                        subsubsector = $("#ddlSubSubSector option:selected").text().split('-');

                        var checkboxPerorangan = $("#<%= checkedPerorangan.ClientID %>");
                        var domCheckboxPerorangan = checkboxPerorangan[0];
                        if (domCheckboxPerorangan.checked)
                            isIndividual = true;
                        else
                            isIndividual = false;
                    }

                    var nilaiemisi = $('#txtNilaiEmisi').val();
                    var wilayahid = $("#ddlWilayah option:selected").val();
                    var kotaid = $("#ddlKota option:selected").val();
                    var alamat1 = $('#txtAlamat1').val();
                    var alamat2 = $('#txtAlamat2').val();
                    var alamat3 = $('#txtAlamat3').val();
                    var telpon = $('#txtTelpon').val();
                    var fax = $('#txtFax').val();
                    var email = $('#txtEmail').val();
                    var kodepos = $('#txtKodePos').val();
                    var website = $('#txtWebsite').val();

                    var unformatinvoicevalue = "";
                    if ($('#<%= hfInvoiceValue.ClientID %>').val() == 0) {
                        invoicevalue = parseFloat($('#<%= hfValue.ClientID %>').val());

//                        unformatinvoicevalue = accounting.unformat($('#hfValue').val(), ",", "."); // Revert to en-US format

                    }
                    else {
                        invoicevalue = parseFloat($('#hfInvoiceValue').val());

//                        unformatinvoicevalue = accounting.unformat($('#hfInvoiceValue').val(), ",", "."); // Revert to en-US format

                    }
                    //var invoicevalue = parseFloat(unformatinvoicevalue);
                    var tarifId = $('#<%= hfTarifID.ClientID %>').val();
                    var id = $('#<%= hfID.ClientID %>').val();
                    var isactive = $('#<%= hfIsActive.ClientID %>').val();

                    var bespelled = $('#<%= hfBeSpelled.ClientID %>').val();

                    var registrationlabel = $('#<%= hfRegistrationLabel.ClientID %>').val();


                    var objrecRegistration = new Object();
                    objrecRegistration.RegistrationID = encodeURIComponent(id);
                    objrecRegistration.PreDebtorName = encodeURIComponent(debtorname);
                    objrecRegistration.NPWP = encodeURIComponent(npwp);
                    objrecRegistration.Address1 = encodeURIComponent(alamat1);
                    objrecRegistration.Address2 = encodeURIComponent(alamat2);
                    objrecRegistration.Address3 = encodeURIComponent(alamat3);
                    objrecRegistration.ZipCode = encodeURIComponent(kodepos);
                    objrecRegistration.Email = encodeURIComponent(email);
                    objrecRegistration.Phone = encodeURIComponent(telpon);
                    objrecRegistration.Fax = encodeURIComponent(fax);
                    objrecRegistration.Website = encodeURIComponent(website);
                    objrecRegistration.RegionID = encodeURIComponent(wilayahid);
                    objrecRegistration.CityID = encodeURIComponent(kotaid);
                    objrecRegistration.InvoiceValue = encodeURIComponent(invoicevalue);
                    objrecRegistration.TarifID = encodeURIComponent(tarifId);
                    objrecRegistration.EmisionTypeID = encodeURIComponent(jenisemisi);
                    objrecRegistration.EmisionValue = encodeURIComponent(nilaiemisi);
                    objrecRegistration.SectorID = encodeURIComponent(sectorid);

                    objrecRegistration.SubSectorID = encodeURIComponent(subsectorid);
                    objrecRegistration.SubSubSectorID = encodeURIComponent(subsubsectorid);
                    objrecRegistration.IsActive = encodeURIComponent(isactive);
                    objrecRegistration.IsIndividual = encodeURIComponent(isIndividual);
                    objrecRegistration.BeSpelled = encodeURIComponent(bespelled);
                    objrecRegistration.SectorCode = encodeURIComponent(sector[0]);
                    objrecRegistration.SubSectorCode = encodeURIComponent(subsector[0]);
                    objrecRegistration.SubSectorName = encodeURIComponent(subsector[1]);
                    objrecRegistration.SubSubSectorName = encodeURIComponent(subsubsector[1]);
                    objrecRegistration.RegistrationLabelName = encodeURIComponent(registrationlabel);
                    objrecRegistration.RegistrationEmisionTypeID = encodeURIComponent(registrationemisiontypeid);
                    if (IsInternalReg.toString() == "" || IsInternalReg == 'undefined') {
                        objrecRegistration.Captcha = encodeURIComponent(captcha);
                        objrecRegistration.CaptchaHash = encodeURIComponent(captchaHash);
                        objrecRegistration.IsExpired = encodeURIComponent(expire);
                    }
                    else {
                        objrecRegistration.Captcha = encodeURIComponent('internal');
                        objrecRegistration.IsExpired = encodeURIComponent(expire);
                    }
                    objrecRegistration.RegistrationEmisionTypeText = encodeURIComponent(registrationemisiontypetext);
                    objrecRegistration.EmisionTypeText = encodeURIComponent(jenisemisitext);

                    objrecRegistration.UserCode = encodeURIComponent(userid);
                    objrecRegistration.Password = encodeURIComponent(password);

                    jsonData = JSON.stringify(objrecRegistration);

                    var handlerUrl = '<%= ResolveUrl("~/ajaxhandler/transaction/recRegistrationhandler.ashx") %>';

                    if (id == 0) {
                        $.ajax({
                            type: 'POST',
                            url: handlerUrl + "?method=insert",
                            contentType: 'application/json',
                            dataType: 'json',
                            data: jsonData,
                            success: function (data) {
                                if (data.IsSuccess) {

                                    alert(data.Message);
                                    var formUrl = '<%= ResolveUrl("~/forms/transaction/recPrintInvoiceform.aspx") %>';

                                    window.open(formUrl + '?action=registrasi&invoiceno=' + data.Data + '&email=' + email + '&userid=' + userid + '&password=' + password, '_blank');

                                    parent.$('#dialog1').dialog('close');

                                    setTimeout("parent.$('#table').trigger('reloadGrid');", 3000);
                                }
                                else {

                                    alert(data.Message);

                                    RefreshCaptcha();

                                }
                            },
                            error: function (response) {
                                var r = JSON.parse(response.responseText);
                                alert("Error Message: " + r.Message);
                            }
                        });

                    }
                    else {
                        CallAjax(handlerUrl, "?method=update", jsonData);
                        parent.$('#dialog1').dialog('close');

                        setTimeout("parent.$('#table').trigger('reloadGrid');", 3000);
                    }

                }
                return false;
            });
        });
    
    </script>
    <script type="text/javascript">

        function ClearText() {
            $('#txtUserId').val('');
        }

        $('#btnCancel').click(function () {

            parent.$('#dialog1').dialog('close');

            return false;
        });
                 
    </script>
    <script type="text/javascript">

        //Match 6 to 15 character string with at least one upper case letter, one lower case letter, and one digit (useful for passwords).
        var passwordStrengthRegex = /((?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,10})/gm;

        var HasError = false;

        $(function () {
            var txtCurrPassword = $("#txtCurrPassword");
            var txtPasswordRegistration = $("#txtPasswordRegistration");
            var txtConfirmPassword = $("#txtConfirmPassword");

            txtPasswordRegistration.blur(function () {
                if (txtPasswordRegistration.val() != "") {
                    var match = String($(this).val()).match(passwordStrengthRegex);
                    if (!match) {
                        $("#txtConfirmPassword").focus();
                        $("#txtPasswordRegistration").val('');
                        $("#txtPasswordRegistration").css({ 'background-color': 'red' });
                        //                    alert("Password must 6 to 15 character string with at least one upper case letter, one lower case letter, and one digit");
                        $("#msgErrorChangePassword").show();
                        $("#msgErrorChangePassword").html("Password harus 6 sampai 10 karakter dengan setidaknya satu huruf besar, satu huruf kecil, dan satu digit angka.");
                        HasError = true;
                    }
                    else {
                        $("#txtPasswordRegistration").css({ 'background-color': '' });
                        HasError = false;
                        $("#msgErrorChangePassword").html("");
                        $("#msgErrorChangePassword").hide();

                        if (txtConfirmPassword.val() != "") {
                            if (txtPasswordRegistration.val() != txtConfirmPassword.val()) {
                                $("#msgErrorChangePassword").show();
                                $("#txtPasswordRegistration").focus();
                                $("#txtConfirmPassword").val('');
                                $("#txtConfirmPassword").css({ 'background-color': 'red' });
                                //                    alert("New Password and Confirm New Password not match!");
                                $("#msgErrorChangePassword").html("Password dan Konfirmasi Password tidak sama!");

                                HasError = true;
                            }
                            else {
                                $("#txtConfirmPassword").css({ 'background-color': '' });
                                HasError = false;
                                $("#msgErrorChangePassword").html("");
                                $("#msgErrorChangePassword").hide();
                            }
                        }
                    }
                }
            });
            txtConfirmPassword.blur(function () {
                //                var match = String($("#txtConfirmPassword").val()).match(passwordStrengthRegex);
                //                if (!match) {
                //                    $("#txtConfirmPassword").focus();
                //                    $("#txtConfirmPassword").css({ 'background-color': 'red' });
                //                    //                    alert("Password must 6 to 15 character string with at least one upper case letter, one lower case letter, and one digit");
                //                    $("#msgErrorChangePassword").show();
                //                    $("#msgErrorChangePassword").html("Konfirmasi Password harus 6 sampai 10 karakter dengan setidaknya satu huruf besar, satu huruf kecil, dan satu digit angka.");

                //                    HasError = true;
                //                }

                //                else 
                if (txtConfirmPassword.val() != "") {
                    if (txtPasswordRegistration.val() != txtConfirmPassword.val()) {
                        $("#msgErrorChangePassword").show();
                        $("#txtPasswordRegistration").focus();
                        $("#txtConfirmPassword").val('');
                        $("#txtConfirmPassword").css({ 'background-color': 'red' });
                        //                    alert("New Password and Confirm New Password not match!");
                        $("#msgErrorChangePassword").html("Password dan Konfirmasi Password tidak sama!");

                        HasError = true;
                    }
                    else {
                        $("#txtConfirmPassword").css({ 'background-color': '' });
                        HasError = false;
                        $("#msgErrorChangePassword").html("");
                        $("#msgErrorChangePassword").hide();
                    }
                }
            });
        });
    </script>
</head>
<body onload="ClearText();StartTimers();" onmousemove="ResetTimers();" onkeydown="ResetTimers();">
    <form id="form1" runat="server">
    <fieldset id="fsUserLogin" runat="server">
        <legend><b>User Login</b></legend>
        <div>
            <table border="0">
                <tr>
                    <td class="spasiRow">
                        Kode User
                    </td>
                    <td width="10">
                        :
                    </td>
                    <td>
                        <asp:TextBox ID="txtUserId" MaxLength="25" runat="server" Width="200"></asp:TextBox>
                    </td>
                    <td class="bintang">
                        *
                    </td>
                </tr>
                <tr>
                    <td class="spasiRow">
                        Password
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <asp:TextBox ID="txtPasswordRegistration" MaxLength="10" TextMode="Password" runat="server"
                            Width="200"></asp:TextBox>
                    </td>
                    <td class="bintang">
                        *
                    </td>
                    <td>
                        <div id="msgErrorChangePassword" style="color: Red; font: 11px Arial,Helvetica,sans-serif;
                            height: 19px; width: 548px;">
                        </div>
                    </td>
                </tr>
                <tr>
                    <td class="spasiRow">
                        Konfirmasi Password
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <asp:TextBox ID="txtConfirmPassword" MaxLength="10" TextMode="Password" runat="server"
                            Width="200"></asp:TextBox>
                    </td>
                    <td class="bintang">
                        *
                    </td>
                </tr>
            </table>
        </div>
    </fieldset>
    <fieldset id="fsProfilDebitur">
        <legend><b>Profil Perusahaan</b></legend>
        <div>
            <table border="0">
                <tr id="trNPWP" runat="server">
                    <td class="spasiRow">
                        NPWP
                    </td>
                    <td width="10">
                        :
                    </td>
                    <td>
                        <asp:TextBox ID="txtNPWP" runat="server" Width="200"></asp:TextBox>
                    </td>
                    <td class="bintang">
                        *
                    </td>
                    <td class="bintang">
                    </td>
                    <td colspan="3">
                        <i><b>Jika user tidak memiliki NPWP, harap hubungi CS OJK.</b></i>
                    </td>
                    <td class="bintang">
                    </td>
                </tr>
                <tr id="trNamaPerusahaan" runat="server">
                    <td class="spasiRow">
                        Nama Perusahaan
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <asp:TextBox ID="txtDebtorName" runat="server" Width="200"></asp:TextBox>
                    </td>
                    <td class="bintang">
                        *
                    </td>
                    <td>
                    </td>
                    <td colspan="3">
                        <b><i>sesuai akta perusahaan.</i></b>
                    </td>
                    <td>
                    </td>
                </tr>
                <tr id="trJenisUsaha" runat="server">
                    <td class="spasiRow">
                        Jenis Usaha
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <asp:TextBox ID="txtddlSector" runat="server" Width="0.01" Visible="true" Style="position: absolute"></asp:TextBox>
                        <asp:DropDownList ID="ddlSector" runat="server" Width="175px">
                        </asp:DropDownList>
                    </td>
                    <td class="bintang">
                        *
                    </td>
                    <td width="10">
                    </td>
                    <td class="spasiRow">
                        Perorangan
                    </td>
                    <td width="10">
                        :
                    </td>
                    <td>
                        <asp:CheckBox ID="checkedPerorangan" runat="server" Checked="false" />
                    </td>
                    <td>
                    </td>
                </tr>
                <tr>
                    <td class="spasiRow" id="tdddlSubSectorLabel" runat="server">
                    </td>
                    <td id="tdddlSubSectorSeparator" runat="server">
                    </td>
                    <td id="tdddlSubSector" runat="server">
                        <asp:TextBox ID="txtddlSubSector" runat="server" Width="0.01" Visible="true" Style="position: absolute"></asp:TextBox>
                        <asp:DropDownList ID="ddlSubSector" runat="server" Width="175px">
                        </asp:DropDownList>
                    </td>
                    <td class="bintang">
                        *
                    </td>
                    <td>
                    </td>
                    <td class="spasiRow">
                        Jenis Registrasi Emisi
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlRegistrationEmisionType" runat="server" Width="206">
                        </asp:DropDownList>
                    </td>
                    <td class="bintang">
                        *
                    </td>
                </tr>
                <tr>
                    <td class="spasiRow" id="tdddlSubSubSectorLabel" runat="server">
                    </td>
                    <td id="tdddlSubSubSectorSeparator" runat="server">
                    </td>
                    <td id="tdddlSubSubSector" runat="server">
                        <asp:TextBox ID="txtddlSubSubSector" runat="server" Width="0.01" Visible="true" Style="position: absolute"></asp:TextBox>
                        <asp:DropDownList ID="ddlSubSubSector" runat="server" Width="175px">
                        </asp:DropDownList>
                    </td>
                    <td class="bintang">
                        *
                    </td>
                    <td>
                    </td>
                    <td class="spasiRow">
                        Jenis Penawaran Umum
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlJenisEmisi" runat="server" Width="206">
                        </asp:DropDownList>
                    </td>
                    <td>
                    </td>
                </tr>
                <tr>
                    <td id="tdAlamat1" runat="server" class="spasiRow">
                        Alamat
                    </td>
                    <td id="tdSeparatorAlamat1" runat="server">
                        :
                    </td>
                    <td id="tdtxtAlamat1" runat="server">
                        <asp:TextBox ID="txtAlamat1" runat="server" Width="200"></asp:TextBox>
                    </td>
                    <td>
                        *&nbsp;
                    </td>
                    <td>
                    </td>
                    <td class="spasiRow">
                        Nilai Emisi (IDR)
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <asp:TextBox ID="txtNilaiEmisi" runat="server" Width="200" Style="text-align: right"></asp:TextBox>
                    </td>
                    <td>
                    </td>
                </tr>
                <tr id="trAlamat2" runat="server">
                    <td class="spasiRow">
                        &nbsp;
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        <asp:TextBox ID="txtAlamat2" runat="server" Width="200"></asp:TextBox>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                    </td>
                    <td class="spasiRow">
                        Propinsi
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlWilayah" runat="server" Width="175px">
                        </asp:DropDownList>
                    </td>
                    <td>
                    </td>
                </tr>
                <tr id="trAlamat3" runat="server">
                    <td class="spasiRow">
                        &nbsp;
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        <asp:TextBox ID="txtAlamat3" runat="server" Width="200"></asp:TextBox>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                    </td>
                    <td class="spasiRow">
                        Kota/Kabupaten
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlKota" runat="server" Width="175px">
                        </asp:DropDownList>
                    </td>
                    <td>
                    </td>
                </tr>
                <tr id="trKodePos" runat="server">
                    <td class="spasiRow">
                        Kode Pos
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <asp:TextBox ID="txtKodePos" runat="server" Width="200"></asp:TextBox>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                    </td>
                    <td class="spasiRow">
                        Telpon
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <asp:TextBox ID="txtTelpon" runat="server" Width="200"></asp:TextBox>
                    </td>
                    <td>
                    </td>
                </tr>
                <tr id="trWebsite" runat="server">
                    <td class="spasiRow">
                        Website
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <asp:TextBox ID="txtWebsite" runat="server" Width="200"></asp:TextBox>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                    </td>
                    <td class="spasiRow">
                        Fax
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <asp:TextBox ID="txtFax" runat="server" Width="200"></asp:TextBox>
                    </td>
                    <td>
                    </td>
                </tr>
                <tr id="trEmail" runat="server">
                    <td class="spasiRow">
                    </td>
                    <td>
                    </td>
                    <td>
                    </td>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                    </td>
                    <td class="spasiRow">
                        Email
                    </td>
                    <td>
                        :
                    </td>
                    <td>
                        <asp:TextBox ID="txtEmail" runat="server" Width="200"></asp:TextBox>
                    </td>
                    <td class="bintang">
                        *
                    </td>
                </tr>
            </table>
        </div>
    </fieldset>
    <fieldset id="fsKonfirmasi">
        <legend><b>Konfirmasi</b></legend>
        <div>
            <table border="0">
                <tr>
                    <td colspan="3">
                        <div id="divlblValidasiNPWP">
                            <asp:Label ID="lblTitleValidasiNPWP" runat="server" ForeColor="#000099" 
                                Font-Bold="True"></asp:Label>
                            <asp:TextBox ID="lblValidasiNPWP" runat="server" TextMode="MultiLine" Enabled="false"
                                BorderStyle="None" BackColor="White" Width="750" ForeColor="#000099"></asp:TextBox>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td colspan="3">
                        <asp:Label ID="lblValidasi" runat="server" ForeColor="#000099" Width="750px"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td>
                    </td>
                    <td>
                    </td>
                </tr>
                <tr>
                    <td colspan="3" style="display: none">
                        <input type="radio" title="" name="rbKonfirmasi" value="1" checked="checked" />
                        Registrasi untuk jenis usaha , dengan user id yang sudah anda miliki sebelumnya
                    </td>
                </tr>
                <tr>
                    <td colspan="3" style="display: none">
                        <input type="radio" name="rbKonfirmasi" value="2" />
                        Registrasi untuk jenis usaha , dengan user id baru
                    </td>
                </tr>
            </table>
        </div>
    </fieldset>
    <div class="captchaLogin" id="tableCaptcha">
        <div class="headCaptcha">
            CAPTCHA</div>
        <div class="imageCaptcha">
            <div style="text-align: center">
                <input type="text" id="txtCaptcha1" name="txtCaptcha1" style="width: 54px !important;" />
            </div>
        </div>
    </div>
    <br />
    <table border="0">
        <tr>
            <td colspan="2">
            </td>
            <td>
                <div style="text-align: right; padding-top: 10px;">
                    <button id="btnCancel" type="button">
                        Batal</button>
                    <button id="btnBack" type="button">
                        Kembali</button>
                    <button id="btnNext" type="button">
                        Lanjut</button>
                    <button id="btnSubmit" type="button">
                        Submit</button>
                </div>
            </td>
        </tr>
        <tr>
            <td colspan="2">
            </td>
            <td>
                <asp:HiddenField ID="hfIsUser" runat="server" />
                <asp:HiddenField ID="hfDebtorID" runat="server" />
                <asp:HiddenField ID="hfNPWP" runat="server" />
                <asp:HiddenField ID="hfSectorID" runat="server" />
                <asp:HiddenField ID="hfSectorCode" runat="server" />
                <asp:HiddenField ID="hfSectorName" runat="server" />
                <asp:HiddenField ID="hfSubSectorID" runat="server" />
                <asp:HiddenField ID="hfSubSectorCode" runat="server" />
                <asp:HiddenField ID="hfSubSectorNames" runat="server" />
                <asp:HiddenField ID="hfSubSubSectorID" runat="server" />
                <asp:HiddenField ID="hfSubSubSectorCode" runat="server" />
                <asp:HiddenField ID="hfSubSubSectorName" runat="server" />
                <asp:HiddenField ID="hfSubSectorName" runat="server" />
                <asp:HiddenField ID="hfID" runat="server" />
                <asp:HiddenField ID="hfIsActive" runat="server" />
                <asp:HiddenField ID="hfInvoiceValue" runat="server" />
                <asp:HiddenField ID="hfValue" runat="server" />
                <asp:HiddenField ID="hfMinValue" runat="server" />
                <asp:HiddenField ID="hfMaxValue" runat="server" />
                <asp:HiddenField ID="hfPercentage" runat="server" />
                <asp:HiddenField ID="hfTarifID" runat="server" />
                <asp:HiddenField ID="hfBeSpelled" runat="server" />
                <asp:HiddenField ID="hfRegistrationLabel" runat="server" />
                <input type="hidden" id="txtExpire" name="txtExpire" value='0' />
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
